const initialState = {
    chatlog:['年轻人不讲武德','闪电五连鞭','耗子尾汁'],
    states:true,
    nickname:'马保国'
}

const chat = (state=initialState,action) => {
    let {type,payload} = action
    switch (type) {
        case 'ADD_CHAT':
            // return {
            //     ...state,
            //     chatlog:[payload,...state.chatlog]
            // }
            return Object.assign({},state,{
                chatlog:[payload,...state.chatlog]
            })

        case 'CHANGE_NAME':
            return Object.assign({},state,{
                nickname:payload
            })

        case 'CHANGE_STATES':
            return Object.assign({},state,{
                states:!state.states
            })
        default:
            return {...state}
    } 
}

export default chat